<!-- 
	주문 내역 조회 상세 페이지
	작성자:문연지
	작성일:2014/10/22
 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
	#head {height:242px}
	#content {position: relative; height:100%; margin:242px 0 100px 0;}
	#footer {height:100px;}
	
	/*
		주문 이미지
	*/
	#content {width:1100px; margin:0 auto; padding-bottom: 20px;}
	#top_line {width:100%; margin:0 auto; height:1px; border-bottom:1px solid #bfbfbf;}	
	#box {width: 1100px; margin:0 auto; } 
	
	/*
		주문내역 테이블
	*/
	#order {width: 1100px; margin:0 auto; }
	.order_title {padding-top: 20px;}
	.order_table {width: 100%; border-top: 2px solid #7e7e7e;}
	.order_table th {padding:13px 0 8px; font-weight:normal; font-size:12px; text-align:center; color:#414141; border-bottom:1px solid #e9e9e9;}
	.order_table td {padding:10px 0; font-weight:normal; font-size:12px; color:#333; border-bottom:1px solid #e9e9e9;}
	.order_table td.left {font-weight:bold; text-align:left;}
	.order_tbody {border-top: 1px solid #bfbfbf;}
	.thead {background-color:#fffbe7;}
	.total .total_left {position:relative; float:left; width:789px; padding:30px 0px 30px 0px; background-color: #c7c6c1; height: 105px;}
	.total .balance_info a {color:#fff; text-decoration:underline;}
	.total .total_right {overflow:hidden; float:right; width:27.5%; margin:0px 8px 0px 0px; text-align:left; background-color: #c7c6c1;}
	.total .total_right th {font-weight:normal; font-size:12px; text-align:right; background-color: #c7c6c1;}
	.total .total_right td {padding-right:33px; text-align:right; color:#414141; line-height:30px;}
	.total .total_right .price th {padding-top:15px; border-top:1px solid #d9d9d9; font-weight:bold; font-size:16px;}
	.total .total_right .price td {padding-top:14px; border-top:1px solid #d9d9d9; font-weight:bold; font-size:16px; color:#fc6800;}

	/*
		주문자정보 테이블, 배송지정보 테이블, 결제정보 테이블
	*/
	.order_title2 {padding-top: 20px;}
	.table_style2 {width:100%; border-top:2px solid #7e7e7e; border-bottom:2px solid #ebebeb;}
	.table_style2 th {width:200px;  padding:8px 0 8px 30px; font-weight:bold; font-size:12px; text-align:left; background:#f9f9f9; border-bottom:1px solid #e9e9e9;}
	.table_style2 td {padding:8px 0 8px 20px; border-bottom:1px solid #e9e9e9;}
</style>
<title>장돌뱅이 ~대한민국 전통시장을 응원합니다~</title>
<script type="text/javascript" src="/Jangdolbaeng2/js/jquery-1.11.1.js"></script>
<script type="text/javascript">

//총 합계
$(document).ready(function(){
	var sum = 0;
	for(i = 0; i < '${product_name_list.size()}'; i++){
		sum =  sum + parseInt($('#' + i).attr('value'));
	}
	$("#total").html(sum + "원");
	$("#total2").html(sum + "원");
	charge(sum);
	
});

//배송료 처리
function charge(sum){
	//alert(sum);
	 var deliveryCharge = 0;
	 
	 if(sum < 30000){
		 deliveryCharge = 2500;
		 $('#charge').html(deliveryCharge + "원");
		 $('#charge2').html(deliveryCharge + "원");
	 } else {
		 deliveryCharge = 0 ;
		 $('#charge').html(deliveryCharge + "원");
		 $('#charge2').html(deliveryCharge + "원");
	 }
	 totalMoney(sum, deliveryCharge);
}

//총 결제 금액
function totalMoney(sum, deliveryCharge){
	//alert(deliveryCharge);
	//alert(sum);
	var result = 0;
	result = sum + parseInt(deliveryCharge);
	//alert(result);
	$('#totalMoney').html(result + '원');
	$('#totalMoney2').html(result + '원');
}

//휴대전화 번호 문자열 자르기
$(document).ready(function(){

	var phone = '${customer.phone}';
	var phone1 = phone.substring(4, 8);
	var phone2 = phone.substring(9, 13);
	
	$('#buyer_cell1').attr('value', phone1);
	$('#buyer_cell2').attr('value', phone2);
});

//주문자와 동일 처리
$(document).ready(function (){

});
</script>
</head>
<body>
<div id="head">
	<%@ include file="/jsp/customer/main_header.jsp" %>
</div>

<!-- 
	주문 이미지
 -->
 

<div id="order">
	<div id="result" width="200px" align="center"
		style="margin:70px 0 50px; 
				font-family:anew; font-size:20pt;">
 	 <span>본 주문은 
 	 <span style="color:red;">
 	 <s:if test='order_vo.ORDER_TYPE=="d" && order_vo.RESULT=="f"'>직접수령 <span style="color:black;">방식이며,</span> 미수령</s:if>
	 <s:elseif test='order_vo.ORDER_TYPE == "d" && order_vo.RESULT== "t"'>수령완료</s:elseif>
	 <s:elseif test='order_vo.RESULT == "f"'>배송준비</s:elseif>
	 <s:elseif test='order_vo.RESULT == "o"'>배송중</s:elseif>
	 <s:else>배송완료</s:else>
 	 상태</span> 
 	  입니다.</span>
 	</div>
	<!-- 
		주문내역 테이블
	-->
	<div style="padding-bottom: 50px;">
		<form name="order_detail" id="detail">
		<p class="order_title">
			<img alt="주문내역확인" src="../img/customer/order_title1.gif">
		</p>
		<table class="order_table">
			<thead class="thead">
				<tr>
					<th colspan="2">상품명</th>
					<th style="width: 12%">상품가격</th>
					<th style="width: 10%">수량</th>
					<th style="width: 13%">합계</th>
				</tr>
			</thead>
			<s:iterator value="product_name_list" status="stat">
				<tbody>	
				<input type="hidden" value="<s:property value="product_seq"/>" name="order_detail.product_seq"/>
					<tr>
						<td width="80" align="center">
							<a href="/Jangdolbaeng2/product/goProduct_detail.action?product_seq=<s:property value="PRODUCT_SEQ"/>">
								<img src="data:image/jpeg;base64,<s:property value="PRODUCT_IMAGE1"/>" width="30">
							</a>
						</td>
						<td align="left" style="font-weight:bold;">
							<a href="/Jangdolbaeng2/product/goProduct_detail.action?product_seq=<s:property value="PRODUCT_SEQ"/>">
							<s:property value="PRODUCT_NAME"/></a>
						</td>
						<td align="center"><s:property value="PRODUCT_PRICE"/></td>
						<input type="hidden" value="<s:property value="QUANTITY"/>" name="order_detail.name"/>
						<td align="center"><s:property value="QUANTITY"/></td>
						<td align="center">
							<input type="hidden" value="<s:property value="PRODUCT_PRICE * QUANTITY"/>" id="<s:property value="#stat.index"/>"/>
							<s:property value="PRODUCT_PRICE * QUANTITY"/>
						</td>
					</tr>
				</tbody>
			</s:iterator>
		</table>
		<div class="total">
			<div class="total_left"></div>
			<div class="balance_info"><a></a></div>
			<table class="total_right" cellspacing="0" cellpadding="0">
				<tr>
					<th>주문수량합계 : </th>
					<td id="total"></td>
				</tr>
				<tr>
					<th>배송료 : </th>
					<td id="charge"></td>
			</tr>
			<tr class="price">
				<th>총 결제금액 : </th>
				<td id="totalMoney"></td>
			</tr>
		</table>
	</div>
	</form>
	</div>
	
	<!-- 
		배송지정보 테이블  
		※value에 정보 가지고 오려면 name vo랑 같게 만들어주기 
	 -->
	 <div style="padding-top: 80px;">
		<form id="orderDeli" name="delivery">
		<input type="hidden" name="delivery.order_seq" value="" id="orderNum">
			<div style="height:20px; margin:14px 0 10px;">
				<p style="float:left;">
					<img src="/Jangdolbaeng2/img/customer/order_title3.gif" alt="배송지 정보" style="padding-right:165px;">
				</p>
			</div>
			<div style="position:relative;">
				<table class="table_style2" style="font-size:10pt;">
					<tbody>	
					<tr>
					    <th>받으시는 분</th>
					    <td>
					    	${delivery_vo.name }
					    </td>
					</tr>
					<tr>
					    <th>전화번호</th>
					    <td id="address_phone_normal" style="display: block;">
					    	${delivery_vo.phone }
					    </td>
					</tr>
					<tr id="domestic_delivery">
					    <th>주소</th>
					    <td>
					    	${delivery_vo.zipcode }<br>
					    	${delivery_vo.address1 }&nbsp;${delivery_vo.address2 }
					    	
					    </td>
					</tr>
					<tr>
					    <th>배송관련 할 말<br></th>
					    <td>
					    	${delivery_vo.delivery_comment }
						</td>
					</tr>
					<tr>
					    <th>장돌뱅이에게 할 말<br></th>
					    <td>
					    	${delivery_vo.jdb2_comment }
						</td>
					</tr>
					</tbody>
				</table>
			</div>
		</form>
	</div>
	
	<!-- ////////////////////////////////////////////////////////////////////////////////////// -->
	<div style="padding-top: 30px;">
		<form id="orderDeli" name="delivery">
		<input type="hidden" name="delivery.order_seq" value="" id="orderNum">
			<div style="height:20px; margin:14px 0 10px;">
				<p style="float:left;">
					<img src="../img/customer/order_title1.gif" alt="주문내역" style="padding-right:165px;">
				</p>
			</div>
			<div style="position:relative;">
				<table class="table_style2" style="font-size:10pt;">
					<tbody>	
					<tr>
					    <th>배송타입</th>
					    <td>
					    	<s:if test='order_vo.ORDER_TYPE == "d"'>직접수령</s:if>
							<s:else>배달</s:else> 
					    </td>
					</tr>
					<tr>
					    <th>배송상태</th>
					    <td>
					    	<s:if test='order_vo.ORDER_TYPE == "d" && order_vo.RESULT == "f"'>미수령</s:if>
							<s:elseif test='order_vo.ORDER_TYPE == "d" && order_vo.RESULT== "t"'>수령완료</s:elseif>
							<s:elseif test='order_vo.RESULT == "f"'>배송준비</s:elseif>
							<s:elseif test='order_vo.RESULT == "o"'>배송중</s:elseif>
							<s:else>배송완료</s:else>
					    </td>
					</tr>
					<tr>
					    <th>주문날짜</th>
					    <td>
					    	<s:property value="order_vo.INPUTDATE"/>
					    </td>
					</tr>
					</tbody>
				</table>
			</div>
		</form>
	</div>
	
	<div align="center" style="height:20px; margin:14px 0 100px;">
		<a href="/Jangdolbaeng2/product/goDelivery.action" >확인</a>
	</div>
	
</div>

<div id="footer">
	<%@ include file="/jsp/customer/main_footer.jsp" %>
</div>
</body>
</html>